home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Game-Power
/
Amiga Game-Power.iso
/
anwendungen
/
gw print
/
structurebrowser_v1.3
/
sources
/
sb.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-20
|
4KB
|
163 lines
/* sb.c
Structure Browser 1.2
(c) 1987 Transactor Magazine
Source and program free to distribute, not to sell.
Structure Browser is designed to grow, to cover more system structures.
Please feel free to lend a hand, but we ask that you help us keep its
growth under control by submitting proposed changes to us either via
mail at the Transactor (address below) or on Compuserve's AmigaForum,
Commodore programming forum (CBMPRG), or Commodore communications forum
(CBMCOM). For details on how to implement new structures, see the magazine
article in The Transactor, Volume 7, Issue 6.
The Transactor
501 Alden Road
P.O. Box 3250
Markham Industrial Park
Markham, Ontario
Canada L3R 9Z9
on Compuserve:
Chris Zamara 76703,4245
Nick Sullivan 76703,4353
March 26, 1987
*/
#include "header/sb.h"
#include "header/trap.h"
extern struct IntuitionBase *IntuitionBase;
extern struct IntuiText ChoiceText[], BackIText;
APTR OpenLibrary();
extern int MyHandler();
int level = 0;
BOOL StartedFromCLI;
/* main
SB starts out at the Library level. So far, only Intuition is covered, so
there is only one menu option at this level - IntuitionBase.
*/
main (argc, argv)
int argc;
char **argv;
{
int choice = -1;
StartedFromCLI = argc > 0;
SetupGadg();
SetTrap();
OpenStuff(); /* open intuition library & window */
while (choice)
{
putHeader("Choose a Library structure", NULL);
ChoiceText[0].IText = (UBYTE *)" Intuition struct Library";
BackIText.IText = (UBYTE *)" Quit Program ";
switch (choice = GetChoice(1))
{
case 1:
PrIntuiBase ("The IntuitionBase structure", IntuitionBase);
break;
}
}
CloseOut();
}
/* PrIntuiBase
All 5 members of the IntuitionBase structure are covered. The handlers
for these are in other modules.
*/
PrIntuiBase (string, IBase)
char *string;
struct IntuitionBase *IBase;
{
static struct StructData structdata[] = {
{ " LibNode", "struct Library", PRNULL, SZ(Library) },
{ " ViewLord", "struct View", PRNULL, SZ(View) },
{ " ActiveWindow", "struct Window *", PRPTR, PTRSIZE },
{ " ActiveScreen", "struct Screen *", PRPTR, PTRSIZE },
{ " FirstScreen", "struct Screen *", PRPTR, PTRSIZE }
};
int i, sum;
int choice = -1;
level++;
while (choice)
{
sum = SetOptionText(string, structdata, (APTR)IBase, DATASIZE, 0);
switch (choice = GetChoice(DATASIZE))
{
case 1:
PrLibrary("The Library structure in IntuitionBase",
&IBase->LibNode);
break;
case 2:
PrView("Intuition's View of the world", &IBase->ViewLord);
break;
case 3:
if (IBase->ActiveWindow)
PrWindow("The currently active window", IBase->ActiveWindow);
break;
case 4:
PrScreen("The currently active screen", IBase->ActiveScreen);
break;
case 5:
PrScreen("The first screen on Intuition's list",
IBase->FirstScreen);
break;
}
}
level--;
}
/* SetTrap
Point the Software Error vector at our own handler (MyHandler(), below)
*/
SetTrap ()
{
MyTask = FindTask(0L);
MyTask->tc_TrapCode = (APTR)MyTrap.MLcode;
MyTrap.Code = MyHandler;
}
/* MyHandler
What to do in case of a Software Error - for example, if we tried to
indirect through a pointer in a structure that has been deallocated since
the user started to examine it.
*/
MyHandler ()
{
CloseOut();
/* print message, or if started from Wbench, just DisplayBeep and exit */
if (StartedFromCLI)
printf("Sorry - got a Software Error condition - trap #%ld\n",
MyTrap.TrapNum);
else
DisplayBeep(IntuitionBase->ActiveScreen);
exit(1000 + MyTrap.TrapNum);
}